﻿@model smartcrm.Models.CustomerList 

<script src="../../Scripts/customer.js"></script>
<form method="post" action="/Customer/Index">
<div class="divSearch">
    <table>
        <tr>
            <td class="label">关键字</td>
            <td>@Html.TextBox("Keywords", null, new { maxlength = "50" })&nbsp;&nbsp;<input type="submit" id="btnSearch" value="搜索" /> </td>
        </tr>
    </table> 
</div>
</form>
@{
    smartcrm.Models.LoginUser user = Session["LoginUser"] as smartcrm.Models.LoginUser;
}
@if (user.PermissionList.Contains("P0101"))
{
    <div class="FR"><input type="button" value="新增" id="btnNew" /> </div>
}
<div class="list">
<table id="tCustomer">
<thead>
<tr>
<th style="width:22%">客户全称</th>
<th style="width:12%">客户简称</th>
<th >地址</th>
<th style="width:12%">电话</th>
<th>快速索引</th>
<th style="width:10%">登录账号</th>
<th style="width:8%">操作</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Customers)
        {
            <tr id="@item.CustomerNo">             
                <td>@Html.DisplayFor(modelItem => item.CustomerFullName)</td>
                <td>@Html.DisplayFor(modelItem => item.CustomerShortName)</td>
                <td>@Html.DisplayFor(modelItem => item.Address)</td>
                <td>@Html.DisplayFor(modelItem => item.Phone)</td>
                <td>@Html.DisplayFor(modelItem => item.SearchKey)</td>
                
                
                <td>
                    @if (item.CanLogin)
                    {
                        @item.LoginId
                        if (user.PermissionList.Contains("P0107"))
                        {
                            <img src="../../Images/grid/key.png" title="重置密码"  onclick="javascript:ResetPassword('@item.CustomerNo','@item.CustomerShortName')" /> 
                        }
                    }
                </td>
                <td>
                @if (user.PermissionList.Contains("P0102"))
                {
                    <img src="../../Images/grid/edit.png" title="编辑" onclick="javascript:EditCustomer('@item.CustomerNo')" />
                }
                @if (user.PermissionList.Contains("P0103"))
                {
                    <img src="../../Images/grid/delete.png" title="删除"  onclick="javascript:DeleteCustomer('@item.CustomerNo')" />
                }
                
                    <img src="../../Images/grid/contacts.png" title="联系人" onclick="javascript:window.location.href='/Contact/Index?sCustomerNo=@item.CustomerNo&cgb=1'" />
                
                </td>
            </tr>
        }
</tbody>
</table>
@Html.Pager("Index", "Customer", Model.RouterDirectory, Model.PagerConfig, "pagerDiv", "pagerDiv", 8, true, false, true, true, false)
</div>

<div id="divCustomer" title="客户信息" style="display:none">      
    <div id="divCustomerContent" style="overflow-y: auto; height: 360px;">          
        @using (Html.BeginForm())
        {
            <table id="tableEdit" class="font85 tableEdit">              
                <tr>
                    <td class="label">客户全称</td>
                    <td>
                        @Html.TextBox("CustomerFullName", null, new { maxlength = "100", @style = "width:260px" })&nbsp;<span class="redStar">*</span>                        
                     </td>
                </tr>
                <tr>
                    <td class="label">客户简称</td>
                    <td>
                        @Html.TextBox("CustomerShortName", null, new { maxlength = "100", @style = "width:260px" })&nbsp;<span class="redStar">*</span> 
                    </td>
                </tr>
                 <tr>
                    <td class="label">地址</td>
                    <td>
                        @Html.TextBox("Address", null, new { maxlength = "100", @style = "width:260px" })
                    </td>
                </tr>
                 <tr>
                    <td class="label">电话</td>
                    <td>
                        @Html.TextBox("Phone", null, new { maxlength = "100", @style = "width:260px" })
                    </td>
                </tr>
                 <tr>
                    <td class="label">快速索引</td>
                     <td>@Html.TextBox("SearchKey", null, new { maxlength = "100" })&nbsp;<span class="redStar">*</span> <img style="width:18px;height:18px; vertical-align:middle; margin:auto" title='建议采用拼音首字母缩写，比如："大武汉"缩写为"dwh"' src="../../Images/grid/help.png" />
                     </td>
                </tr>   
                <tr>
                    <td class="label">备注</td>
                    <td>@Html.TextArea("Description", null, new { maxlength = "8000" })</td>
                </tr>
                <tr>
                    <td class="label">是否可登录</td>
                    <td>
                        @Html.CheckBox("CanLogin")&nbsp;<img style="width:18px;height:18px; vertical-align:middle; margin:auto" title='启用登录后，客户可登录系统进行自助服务，比如查询订单状态等' src="../../Images/grid/help.png" />
                    </td>
                </tr>      
            </table> 
            <br />
            
            @Html.Hidden("CustomerNo")     
        }
    </div>  
    <div style="text-align:right;">  
     <span id="errorMessage" class="errorSpan"></span>       
       <input type="button" id="btnSave" value="保存" />
       <input type="button" id="btnCancel" value="取消" />    
    </div>  
</div>  

<div id="divPassword" title="重置密码" style="display:none">      
    <div id="divPasswordContent" style="overflow-y: auto; height: 60px;">          
       
    </div>  
    <div style="text-align:right;">      
        <input type="button" onclick="javascript:$('#divPassword').dialog('close');" value="关闭" />      
    </div>  
</div>  